<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" import="com.service.ProductService,com.model.Product,java.util.* "%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>最热</title>
</head>
<body>
	<br/>
	<br/>
	<div class="wrap">
		<div class="best-sellers">
			<div class="best-sellers-head">
				<h3>最热回收</h3>
			</div>
			<!-- <div class="best-sellers-menu">
				<ul>
					<li><a class="active" href="#">纸类</a></li>
					<li><a href="#">塑料</a></li>
					<li><a href="#">金属</a></li>
					<li><a href="#">电池</a></li>
				</ul>
			</div> -->
			<div class="clearfix"></div>
		</div>
		<div class="device">
			<div class="course_demo">
				<ul id="flexiselDemo">
					<% 
					Product product=new  Product();
					ProductService service = new ProductService();
					List<Product> populars =service.query_user2(product);
					request.setAttribute("populars",populars);
				 %>
				 <c:forEach items="${populars}" var="pop" begin="0" end="5">
					<li>
						<div class="ipad text-center">
							<img src="${pop.pimage }" alt="" />
							<h4>${pop.pname}</h4>
							<h3>${pop.pprice}</h3>
							<ul>
								<li><i class="cart-1"></i></li>
								<li><button class="cart-button btn-addtocart" id="">出售页</button></li>
							</ul>
							<div class="clearfix"></div>
						</div>
					</li>
					
				</c:forEach>	
				</ul>
			</div>
		</div>
	</div>
	<script type="text/javascript">
		$(function() {
			$(".btn-addtocart").click(function() {
				//alert($(this).prev().prev().val());
				var uid =$(this).prev().prev().val();
				if(uid==0||uid==null||uid==" "){
					alert("请登录后再进行该操作！");
					return;
				}
				//alert($(this).prev().val());
				//获取参数
			 	/* var e=$(this);
				while(e.prev().val()!=null){
					e=e.prev();
					alert(e.val());
				} */
				
				$.ajax({
					url : "cart",
					type : "post",
					data : {
						"action":$(this).prev().val(),
						"uid":$(this).prev().prev().val(),
						"weight":$(this).prev().prev().prev().val(),
						"pprice":$(this).prev().prev().prev().prev().val(),
						"pname" :$(this).prev().prev().prev().prev().prev().val(),
						"pid" : $(this).prev().prev().prev().prev().prev().prev().val(),
						"pimage" : $(this).prev().prev().prev().prev().prev().prev().prev().val(),
					},
					dataType : "text",
					success : function(result) {
						if (result == '1') {
							alert("操作成功！");
						} else {
							alert("操作失败！");
						}
					},
					error : function() {
						alert("系统发生错误，请联系管理员！");
					}
				})

			})
		})
	</script>
</body>
</html>